function save(){
    var name = document.getElementById("name").value;
    var num = document.getElementById("num").value;
    var level = document.getElementById("level").value;
    var region= document.getElementById("region").value;
    var fatherNum = document.getElementById("fatherNum").value;

    var table = document.getElementsByTagName("tbody")[0];
    var tr = table.insertRow(table.rows.length);
    tr.insertCell(0).innerHTML = name;
    tr.insertCell(1).innerHTML = num;
    tr.insertCell(2).innerHTML = level;
    tr.insertCell(3).innerHTML =region;
    tr.insertCell(4).innerHTML = fatherNum;
    tr.insertCell(5).innerHTML = '<a onclick="modify(this)"><i class="fa fa-wrench"></i> 修改</a>';
    tr.insertCell(6).innerHTML = '<a onclick="remove(this)"><i class="fa fa-times"></i> 删除</a>';
    alert("新增成功");
    var name = document.getElementById("name");
    var num = document.getElementById("num");
    var level = document.getElementById("level");
    var region= document.getElementById("region");
    var fatherNum = document.getElementById("fatherNum");
    name.value = "";
    num.value = "";
    level.value = "";
    region.value = "";
    fatherNum.value="";
}
function cancel(){
    var name = document.getElementById("name");
    var num = document.getElementById("num");
    var level = document.getElementById("level");
    var fatherNum = document.getElementById("fatherNum");
    name.value = "";
    num.value = "";
    level.value = "";
    fatherNum.value="";
}
// function modify(cell){
//     tr = cell.parentNode.parentNode;//input --> td --> tr
//     var text = tr.cells[2].innerText;
//     //console.log(tr.cells[2].innerText);
//     tr.cells[2].innerHTML = '<input id="comment' + tr.rowIndex + '" name="comment"' +
//         'class="form-control" aria-required="true">';
//     tr.cells[5].innerHTML = '<a onclick="confirm(this)"><i class="fa fa-wrench"></i> 确认</a>';
//     var comment = document.getElementById("comment" + tr.rowIndex);
//     comment.value = text;
// }
// function confirm(cell){
//     tr = cell.parentNode.parentNode;//input --> td --> tr
//     console.log(tr.cells[2].innerText);
//     tr.cells[2].innerHTML = document.getElementById('comment' + tr.rowIndex).value;
//     tr.cells[5].innerHTML = '<a onclick="modify(this)"><i class="fa fa-wrench"></i> 修改</a>';
// }
function remove(cell){
    var tr=cell.parentNode.parentNode;//input --> td --> tr
    var table=document.getElementsByTagName("table")[0]
    table.deleteRow(tr.rowIndex);
}